﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LibraryONTrack.dao;
using LibraryONTrack.dto;

namespace LibraryONTrack.UI
{
	public partial class MainFormold : Form
	{
//    const int WM_SYSCOMMAND = 274;
//    const int SC_CLOSE = 61536;

//    RosterDAO _rosterDAO = null;
//    private int currentTeacherIndex;
//    private bool _skipValidation;

//    private bool _initialized = false;
//    public MainFormold()
//    {
//      InitializeComponent();
//      InitializeAddBooks();
//    }

//    private void InitializeAddBooks()
//    {
//      _rosterDAO = new RosterDAO();

////			TeacherComboBox.DataSource = new BindingList<Teacher>(_rosterDAO.GetAll());
//      TeacherComboBox.DataSource = rost
//      TeacherComboBox.ValueMember = "Id";
//      TeacherComboBox.DisplayMember = "Name";
//      StudentComboBox.ValueMember = "Id";
//      StudentComboBox.DisplayMember = "Name";
//      currentTeacherIndex = TeacherComboBox.SelectedIndex;

//    }

//    private void TeacherComboBox_SelectedIndexChanged(object sender, EventArgs e)
//    {
//      currentTeacherIndex = TeacherComboBox.SelectedIndex;

//      StudentComboBox.DataSource = new BindingList<Student>(_rosterDAO.getRosterStudents((Teacher)TeacherComboBox.SelectedItem));
//      StudentComboBox.ValueMember = "Id";
//      StudentComboBox.DisplayMember = "Name";


//    }

//    private void TeacherComboBox_Validating(object sender, CancelEventArgs e)
//    {
//      if (!_skipValidation)
//      {
//        string newTeacherName = TeacherComboBox.Text;
//        BindingList<Teacher> teachersBindingList = (BindingList<Teacher>)TeacherComboBox.DataSource;
//        if (teachersBindingList.FirstOrDefault(p => p.Name == newTeacherName) == null)
//        {
//          if (MessageBox.Show("Add new roster for teacher '" + newTeacherName + "'?", "Unknown teacher, add?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
//          {
//            teachersBindingList.Add(_rosterDAO.addRoster(newTeacherName));
//            TeacherComboBox.Text = newTeacherName;
//          }
//          else
//          {
//            TeacherComboBox.SelectedIndex = currentTeacherIndex;
//            TeacherComboBox.Focus();
//          }
//        }
//      }
//    }

//    protected override void WndProc(ref Message m)
//    {
//      if (m.Msg == WM_SYSCOMMAND && m.WParam.ToInt32() == SC_CLOSE)
//      {
//        _skipValidation = true;
//      }
//      base.WndProc(ref m);
//    }

	}
}
